
 <template>
 	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" size="tiny">
    <i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
   <div class="bt">修改</div>
 		<!-- <i class="el-icon-close close" @click="cancel"></i> -->
 		<el-form label-width="100px" class="form">
 			<el-form-item label="开始时间">
 				<el-input v-model="form.sj"  placeholder="请输入开始时间" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="结束时间">
 				<el-input v-model="form.jssj"  placeholder="请输入结束时间" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="内容">
 				<el-input v-model="form.nr"  placeholder="请输入工作内容" type="textarea" :rows="4" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="是否完成">
 				<!-- <el-input v-model="form.isok"  placeholder="请输入" class="select-block"></el-input> -->
        <el-tooltip :content="'Switch value: ' + sx" placement="top" class="sx" >
  				<el-switch  v-model="form.isok" on-color="#13ce66" off-color="#ff4949" width="75"  off-text="未完成" on-text="完成" on-value="Y" off-value="N"></el-switch>
  			</el-tooltip>
 			</el-form-item>
 		</el-form>
 		<el-button type="info" class="submit" @click="submit">修改</el-button>
 	</el-dialog>
 </template>
 <script type="text/javascript">
 	import qs from 'qs'
 	export default {
 		props: ['params'],
 		data() {
 			return {
 				form: {
 sj :'',
 jssj :'',
 nr :'',
 isok :'',
 					id:''
 				},
        sx: 'Y',
 			}
 		},
 		created() {
  		 this.form.id = this.params.row.id;
          this.loadinfo();
 		},
 		methods: {
 			loadinfo(){
 				 var logininfo = JSON.parse(localStorage.logininfo) ;
 				 this.axios.get(this.$store.state.api+'rw/info',{
 						 params:{
 							 xxid:logininfo.xxid,
 							 yhid:logininfo.id,
 							 id:this.form.id
 						 }
 					}).then( res =>  {
 							this.form=res.data.data
 					 }).catch(res => {
 						 alert("服务器异常");
 			 				this.$emit('close', { type: 'info', cancel: true });
 					 })
 			},
 			 submit() {
 				//检测
 				this.$store.state.loading = true;
 				/*if(!this.form.id) {
 					this.$message.warning('请填写分类');
 					this.$store.state.loading = false;
 					return;
 				}*/
 				//装载数据
 				var logininfo = JSON.parse(localStorage.logininfo);
 				var params2 = qs.stringify({
 						id: this.form.id,
 						sj: this.form.sj,
 						jssj: this.form.jssj,
 						nr: this.form.nr,
 						isok: this.form.isok,
 						yhid: logininfo.id,
 						xxid: logininfo.xxid
 					})
 				//执行
 				    this.axios.post(this.$store.state.api + 'rw/update',  params2 )
 						.then(res => {
 							if(res.data.code == 1) {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$store.state.loading = false;
 							} else {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$store.state.loading = false;
 							}
 						}).catch(res => {
 							alert("服务器异常");
 							this.$store.state.loading = false;
 						})
 			},
 			cancel() {
 				this.$emit('close', { type: 'edit', cancel: true })
 			}
 		}
 	}
 </script>
 <style lang="less" scoped>
 .wrap {
   text-align: center;
 }
.bt{
     position: absolute;
     width: 100%;
     height: 50px;
     margin: 0 auto;
     top:0;
     left:0;
     background: #50BFFF;
     margin-bottom: 20px;
     color:white;
     text-align:left;
     line-height: 50px;
     font-size: 17px;
     padding-left: 15px;
   }
 .form {
   text-align: left;
   margin-top: 20px;
 }
 .input {
            display: inline-block;
        }
 .select-block {
   display: block;
   width: 85%;
 }
 .submit {
   width: 120px;
 }
 </style>
